//
//  NSString+CountWithStr.m
//  Day6
//
//  Created by wenjim on 17/10/12.
//  Copyright © 2017年 WenJim. All rights reserved.
//

#import "NSString+CountWithStr.h"

@implementation NSString (CountWithStr)

+ (int)countWithStr:(NSString *)str
{
    int count = 0;
    
    for (int i = 0; i < str.length; i++) {
        unichar c = [str characterAtIndex:i];
        //        NSLog(@"%c",c);
        
        if (c >= '0' && c<= '9') {
            count ++;
        }
        
    }
    return count;
}


-(int)countNumber
{
    int countNumber = 0;
    
    for (int i = 0; i < self.length; i ++) {
        unichar c = [self characterAtIndex:i];
        //        NSLog(@"%c",c);
        
        if (c >= '0' && c<= '9') {
            countNumber ++;
        }
    }
    return countNumber;
}

@end
